home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Technotools
/
Technotools (Chestnut CD-ROM)(1993).ISO
/
lang_c
/
msqc25t1
/
cat.c
< prev
next >
Wrap
C/C++ Source or Header
|
1990-09-07
|
817b
|
37 lines
/* cat.c: concatenate files or list file to stdio */
#include <stdio.h> /* for file manipulation */
main (argc, argv)
int argc; /* count of the command line arguments */
char *argv[]; /* actual command line arguments */
{
char string[BUFSIZ]; /* line read in from the file */
FILE *fopen(), *fpin; /* file pointers */
int count; /* counter of command line arguments */
/* find out if enought arguments are present */
if(argc < 2)
exit(1);
for (count = 1; count < argc; count++)
{
if ((fpin = fopen(argv[count], "r")) == NULL)
{
fprintf(stderr, "cat: error in file name %s\n",
argv[count]);
exit(1);
}
while (fgets(string, BUFSIZ, fpin) != NULL)
fputs(string, stdout);
fclose(fpin);
}
}